//
//  HWShangpingxiangqingViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/10/12.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWShangpingxiangqingViewController.h"
#import "ZYProGressView.h"
#import "HWFuLishangpingxiangqingTableViewCell.h"
#import "HWExchangeViewController.h"
#import "HWLoginController.h"
#import "HWxiaohaojifenView.h"


@interface HWShangpingxiangqingViewController ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,WKUIDelegate,WKNavigationDelegate>
{
    ZYProGressView *progress;
}
@property(strong,nonatomic)UITableView *mainaTableVie;
@property(strong,nonatomic)UIView *hederView;  // 设置Tabelview 的头部
@property(strong,nonatomic) UIView *footView;
@property(strong,nonatomic) UIImageView *miaoshuImageView;


// 底部UiView
@property(strong,nonatomic) UIView *lowerPartView;
@property(strong,nonatomic) UILabel *jifenlabel;


// 设置HeadeView控件
@property(strong,nonatomic) UICollectionView *maincollectionView;
@property(strong,nonatomic) UILabel *numberNamelabel;

// 有关商品描述的控价
@property(strong,nonatomic)UILabel *shangpingmingchenlabel;
@property(strong,nonatomic)UILabel *banFenbiLabel;

@property(strong,nonatomic)UILabel *shengyuShulianLabel;



@property(strong,nonatomic) NSDictionary *dataDic;
@property(strong,nonatomic) NSMutableArray *dataMuArr;

@property(strong,nonatomic) UIButton *pinglunButon;

@property(strong,nonatomic) NSString *shancangStr;




@end

@implementation HWShangpingxiangqingViewController


-(UITableView *)mainaTableVie {
    
    if (_mainaTableVie == nil
        ) {
        
        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW,kScreenH-44) style:UITableViewStylePlain];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
        
        
    }
    return   _mainaTableVie ;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupUI];
    //发送请求
    [self sendTheRequest];
    
    
    
    
}


// 发送网络请求
- (void)sendTheRequest {
    
    
    
    
    
    
    
    
    NSString *uidStr = [NSString stringWithFormat:@"%@",[HWLocallyStoredData getLoginUserID]];
    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
    
    //   NSString *typeStr =  [NSString stringWithFormat:@"%@",@"1"];
    
    NSString *singStr = [NSString stringWithFormat:@"%@%@%@",uidStr,tStr,@"fsd213ewdsadqwe2121213edsad"];
    
    NSString *singMD5 = [WMUtil md5HexDigest:singStr];
    
    
    NSDictionary *parametes = nil;
    if ([uidStr isEqualToString:@""]) {
        
        
        parametes = @{
            @"ios" : @"1",
            @"ct" :  @"app",
            @"ac" : @"mall_info",
            @"id" :self.goodsID,
            
            
            
            
        };
        
    } else {
        
        parametes = @{
            @"ios" : @"1",
            @"ct" :  @"app",
            @"ac" : @"mall_info",
            @"id" :self.goodsID,
            @"uid" :uidStr,
            @"t":tStr,
            @"sign" : singMD5,
            
        };
        
        
    }
    
    
    
    
    
    self.dataMuArr = [[NSMutableArray alloc]init];
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        
        if ([codeStr intValue] == 1) {
            self.dataDic = response[@"data"];
            [self.dataMuArr addObject:self.dataDic[@"goods_img"]];
            self.shangpingmingchenlabel.text = [NSString stringWithFormat:@"%@", self.dataDic[@"goods_name"]];
            
            NSString *bfb = [NSString stringWithFormat:@"%@",self.dataDic[@"bfb"]];
            CGFloat  bafen = [bfb floatValue]/100;
            
            
            NSString *bafenStr = [NSString stringWithFormat:@"%f",bafen];
            
            progress.progressValue = bafenStr;
            //  goods_number
            // self.shengyuShulianLabel.text = @"剩余数量：8";
            
            //   self.banFenbiLabel.text = [NSString stringWithFormat:@"%@%%",bfb];
            
            NSString *shenyushu = [HWjianzhiduiObject keylocalization:@"剩余数量"];
            
            //   self.banFenbiLabel.text = [NSString stringWithFormat:@"剩余数量：%@",self.dataDic[@"goods_number"]];
            
            self.banFenbiLabel.text = [NSString stringWithFormat:@"%@：%@",shenyushu,self.dataDic[@"goods_number"]];
            
            self.shengyuShulianLabel.text = [NSString stringWithFormat:@"剩余数量：%@",self.dataDic[@"goods_number"]];
            self.shengyuShulianLabel.hidden = YES;
            
            NSString   *is_shoucang  = [NSString stringWithFormat:@"%@",response[@"data"][@"is_shoucang"]];
            
            
            
            self.shancangStr = is_shoucang;
            
            if ([is_shoucang intValue] == 0) {
                
                [self.pinglunButon setImage:[UIImage imageNamed:@"weishoucang_wu"] forState:UIControlStateNormal];
                
                
                
            } else {
                
                //   [self.pinglunButon setImage:[UIImage imageNamed:@"youxiangxiangqing"] forState:UIControlStateNormal];
                //    weishoucang_gaolianglailai
                [self.pinglunButon setImage:[UIImage imageNamed:@"weishoucang_gaolianglailai"] forState:UIControlStateNormal];
            }
            
            
            
            // [NSString stringWithFormat:@"%@", self.dataDic[@"goods_name"]];
            
            NSString *jifenStr = [NSString stringWithFormat:@"所需积分：%@",self.dataDic[@"market_price"]];
            self.jifenlabel.attributedText =  [WMUtil attributedStringWithText:jifenStr withRangText:self.dataDic[@"market_price"] withColor:RGB(253, 178, 50) withFont:[UIFont systemFontOfSize:14]];
            
            [self tianjiantupian];
            [self.maincollectionView reloadData];
            
        } else {
            
            [MBProgressHUD showError:response[@"message"]];
            
            
        }
        
        
        
    } failure:^(NSString *error) {
        
        [MBProgressHUD showError:@"查询游戏失败"];
        
    }];
    
    
    
    
}


- (void)tianjiantupian {
    
    
    
    
    
    
    NSString  *str  = [self decodeBase64ToImage:self.dataDic[@"goods_desc"]];
    
    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
    configuration.userContentController = [[WKUserContentController alloc] init];
    
    
    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-(200+13+5)-CF_NavHeight-44-10) configuration:configuration];
    
    webView.UIDelegate = self;
    webView.navigationDelegate = self;
    [self.footView addSubview:webView];
    [webView loadHTMLString:str baseURL:nil];
    
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    
    [webView evaluateJavaScript:@"Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight)" completionHandler:^(id Result, NSError * error) {
        NSString *heightStr = [NSString stringWithFormat:@"%@",Result];
        
        CGFloat height = heightStr.floatValue+25.00;
        //网页加载完成
        NSLog(@"加载网页高度：%f",height);
        webView.frame = CGRectMake(0, 0, kScreenW, height);
        self.footView.frame = CGRectMake(0, 0, kScreenW, height);
        self.mainaTableVie.tableFooterView = self.footView;
    }];
    
    //    [webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
    //    [webView evaluateJavaScript:@"document.documentElement.style.webkitUserSelect='none';" completionHandler:nil];
    
    
    //HTML5的高度
    //    [webView evaluateJavaScript:@"Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight)" completionHandler:^(id _Nullable, NSError * _Nullable error) {
    //
    //    }];
    //    NSString *htmlHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"];
    //    //HTML5的宽度
    //    NSString *htmlWidth = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollWidth"];
    //   //宽高比
    //    float i = [htmlWidth floatValue]/[htmlHeight floatValue];
    //
    //    //webview控件的最终高度
    //    float height = kScreenW/i;
    //
    //    //后面的代码
    //
    //    NSLog(@"高度 %@",htmlHeight);
    //
    //    webView.frame = CGRectMake(0, 0, kScreenW, [htmlHeight floatValue]);
    //    self.footView.frame = CGRectMake(0, 0, kScreenW, [htmlHeight floatValue]);
    //    self.mainaTableVie.tableFooterView = self.footView;
}


- (NSString  *)decodeBase64ToImage:(NSString *)strEncodeData {
    
    
    NSData *data = [[NSData alloc]initWithBase64EncodedString:strEncodeData options:NSDataBase64DecodingIgnoreUnknownCharacters];
    
    NSString *string =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    
    
    return string;
    
}



- (void)setupUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"商品详情";
    self.navigationItem.title = [HWjianzhiduiObject keylocalization:@"商品详情"];
    
    
    
    [self addTaviewkongjian];
    [self addtaviewheadeView];
    [self addfooterView];
    
    
    [self addLowerPartView];
    
    
}

// 添加控件
- (void)addTaviewkongjian {
    [self.view addSubview:self.mainaTableVie];
}
// 添加Tabview的头部
-(void)addtaviewheadeView {
    // self.hederView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 200+90+13+5)];
    
    self.hederView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 200+90+13+5-50)];
    self.hederView.backgroundColor = [UIColor redColor];
    self.mainaTableVie.tableHeaderView  =  self.hederView;
    
    // 放的是有关UIIamgeView
    [self addHederView];
    //放的是线条数量
    [self addmiashuView];
    
}



- (void)addfooterView {
    
    //  self.footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW,kScreenH-(200+90+13+5)-CF_NavHeight-44)];
    
    self.footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW,kScreenH-(200+13+5)-CF_NavHeight-44)];
    
    self.footView.backgroundColor = [UIColor whiteColor];
    self.mainaTableVie.tableFooterView =  self.footView ;
    
    self.miaoshuImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 100)];
    [self.footView addSubview:self.miaoshuImageView];
    
    
    
}



- (void)addHederView  {
    
    UIView *tupianView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 200)];
    tupianView.backgroundColor = [UIColor whiteColor];
    // tupianView.backgroundColor = [UIColor redColor];
    
    [self.hederView  addSubview:tupianView];
    
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.scrollDirection  =  UICollectionViewScrollDirectionHorizontal;
    
    //    layout.minimumLineSpacing = 18;
    
    //      CGFloat juanju  = (kScreenW - 24*CFLScaleValue*2-62*CFLScaleValue*3-78*CFLScaleValue)/2;
    // layout.minimumInteritemSpacing = 1;
    layout.minimumLineSpacing = 0;
    //   layout.headerReferenceSize = CGSizeMake(kScreenW, 142);  //设置headerView大小
    self.maincollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 200) collectionViewLayout:layout];
    // self.maincollectionView.showsHorizontalScrollIndicator = NO;
    self.maincollectionView.delegate = self;
    self.maincollectionView.dataSource = self;
    self.maincollectionView.alwaysBounceVertical = NO;
    self.maincollectionView.pagingEnabled = YES;
    self.maincollectionView.backgroundColor = [UIColor whiteColor];
    self.maincollectionView.showsHorizontalScrollIndicator = NO;
    self.maincollectionView.showsVerticalScrollIndicator = NO;
    self.maincollectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    //   self.maincollectionView.contentInset = UIEdgeInsetsMake(0, 24*CFLScaleValue, 0, 24*CFLScaleValue);
    //  [self.maincollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];  //  一定要设置
    [self.maincollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellID"];
    //  [self.maincollectionView  registerNib:[UINib nibWithNibName:@"HWJinXuanCell" bundle:nil] forCellWithReuseIdentifier:@"cellID"];
    self.maincollectionView.userInteractionEnabled = YES;
    [tupianView   addSubview:self.maincollectionView];
    
    
    self.numberNamelabel =  [[UILabel alloc]initWithFrame:CGRectMake(0, 200-30, kScreenW-10, 30)];
    self.numberNamelabel.text = @"1/5";
    self.numberNamelabel.textColor = RGB(51, 51, 51);
    self.numberNamelabel.hidden = YES;
    self.numberNamelabel.font = [UIFont systemFontOfSize:16];
    self.numberNamelabel.textAlignment = NSTextAlignmentRight;
    
    [tupianView addSubview:self.numberNamelabel];
    
}

// 添加一些描述的Uiview
- (void)addmiashuView {
    
    UIView *miashuView = [[UIView alloc]initWithFrame:CGRectMake(0, 200, kScreenW, 90+13+5)];
    miashuView.backgroundColor = [UIColor whiteColor];
    [self.hederView addSubview:miashuView];
    
    
    UIView *xiantianView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 1)];
    xiantianView.backgroundColor = RGB(232, 232, 242);
    [miashuView addSubview:xiantianView];
    
    
    self.shangpingmingchenlabel =  [[UILabel alloc]initWithFrame:CGRectMake(65, 0, kScreenW-130, 40)];
    self.shangpingmingchenlabel.text = @"Apple IPhone 11（A2223） 64G";
    self.shangpingmingchenlabel.textColor = RGB(51, 51, 51);
    // self.shangpingmingchenlabel.backgroundColor = [UIColor redColor];
    self.shangpingmingchenlabel.font = [UIFont systemFontOfSize:14];
    self.shangpingmingchenlabel.numberOfLines = 2;
    
    self.shangpingmingchenlabel.textAlignment = NSTextAlignmentCenter;
    [miashuView addSubview:self.shangpingmingchenlabel];
    
    
    progress = [[ZYProGressView alloc]initWithFrame:CGRectMake(12,  self.shangpingmingchenlabel.bottom+9, 230, 6)];
    progress.time = 1;
    //  progress.progressColor  =  RGB(26, 113, 255);
    progress.progressColor  =  RGB(246, 106, 5);
    progress.bottomColor = RGB(224, 224, 224);
    
    progress.progressValue = @"0.7";
    [miashuView addSubview:progress];
    
    
    self.banFenbiLabel =  [[UILabel alloc]initWithFrame:CGRectMake(progress.rightX+10, self.shangpingmingchenlabel.bottom+9-3, kScreenW-10, 11)];
    self.banFenbiLabel.text = @"70%";
    self.banFenbiLabel.textColor = RGB(51, 51, 51);
    self.banFenbiLabel.font = [UIFont systemFontOfSize:14];
    // self.banFenbiLabel.textAlignment = NSTextAlignmentCenter;
    //    self.banFenbiLabel.backgroundColor = [UIColor redColor];
    [miashuView addSubview:self.banFenbiLabel];
    
    
    self.shengyuShulianLabel =  [[UILabel alloc]initWithFrame:CGRectMake(0, self.banFenbiLabel.bottom+14, kScreenW, 14)];
    self.shengyuShulianLabel.text = @"剩余数量：8";
    self.shengyuShulianLabel.textColor = RGB(51, 51, 51);
    self.shengyuShulianLabel.font = [UIFont systemFontOfSize:13];
    self.shengyuShulianLabel.textAlignment = NSTextAlignmentCenter;
    [miashuView addSubview:self.shengyuShulianLabel];
    
    
    
    
    
}







// 添加低部UIview
- (void)addLowerPartView {
    
    self.lowerPartView = [[UIView alloc]initWithFrame:CGRectMake(0, kScreenH-60-CF_TabbarSafeBottomMargin, kScreenW, 60+CF_TabbarSafeBottomMargin)];
    // self.lowerPartView.backgroundColor = [UIColor yellowColor];
    self.lowerPartView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.lowerPartView];
    
    //这个是收藏
    
    NSString *shoucan = [HWjianzhiduiObject keylocalization:@"收藏"];
    
    self.pinglunButon = [UIButton  createNormalButtonWithFrame:CGRectMake(20, 10, 40+10, 22+3+17) Image:@"weishoucang_wu" Title:shoucan font:10 imageSize:CGSizeMake(26, 26)];
    [self.pinglunButon layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:3];
    [self.pinglunButon setTitleColor:RGB(68, 68, 68) forState:UIControlStateNormal];
    
    
    [self.pinglunButon addTarget:self action:@selector(shoucangTap) forControlEvents:UIControlEventTouchUpInside];
    
    [self.lowerPartView addSubview: self.pinglunButon];
    
    
    
    
    
    
    
    self.jifenlabel =  [[UILabel alloc]initWithFrame:CGRectMake(12, 0, 180, 44)];
    self.jifenlabel.text = @"所需积分：";
    self.jifenlabel.font = [UIFont systemFontOfSize:14];
    self.jifenlabel.textColor = RGB(51, 51, 51);
    self.jifenlabel.attributedText =  [WMUtil attributedStringWithText:@"所需积分：600" withRangText:@"600" withColor:RGB(253, 178, 50) withFont:[UIFont systemFontOfSize:14]];
    self.jifenlabel.hidden = YES;
    [self.lowerPartView addSubview: self.jifenlabel];
    
    UIView *fengeview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 1)];
    fengeview.backgroundColor = RGB(232, 232, 232);
    [self.lowerPartView addSubview:fengeview];
    
    NSString *lijiduihua = [HWjianzhiduiObject keylocalization:@"立即兑换"];
    
    
    
    UIButton *butt  = [UIButton setButtonWithFrame:CGRectMake(kScreenW-84-12, 15, 84, 30) Title:lijiduihua Image:nil Font:13 Color:RGB(255, 255, 155) Target:self Selector:@selector(duihuanTap)];
    butt.backgroundColor = blueBackgroundBT;
    butt.layer.cornerRadius = 15;
    butt.layer.masksToBounds = YES;
    butt.backgroundColor   = QCchunseshensetupian;
    
    [self.lowerPartView addSubview:butt];
    
    
    
    UIButton *butt1 = [UIButton setButtonWithFrame:CGRectMake(kScreenW-84-12-84-10, 7, 84, 30) Title:@"加入收藏" Image:nil Font:13 Color:RGB(255, 255, 155) Target:self Selector:@selector(shoucangTap)];
    butt1.backgroundColor = blueBackgroundBT;
    butt1.layer.cornerRadius = 15;
    butt1.layer.masksToBounds = YES;
    butt1.hidden = YES;
    [self.lowerPartView addSubview:butt1];
    //
    //    UIButton *butt1  = [UIButton setButtonWithFrame:CGRectMake(7, 0, 50, 44) Title:@"收藏" Image:@"details_sellect_a" Font:10 Color:RGB(178, 178, 178) Target:self Selector:@selector(shoucangTap:)];
    //    [butt1 setImage:[UIImage imageNamed:@"details_sellect_b"] forState:UIControlStateSelected];
    //
    //   // butt1.backgroundColor = RGB(38, 154, 255);
    //    [butt1 layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:5];
    //    [self.lowerPartView addSubview:butt1];
    //
    //    UIButton *butt2  = [UIButton setButtonWithFrame:CGRectMake(kScreenW-65+7, 0, 50, 44) Title:@"分享" Image:@"details_share_a" Font:10 Color:RGB(178, 178, 178) Target:self Selector:@selector(fenxiangTap:)];
    //
    //
    //    // butt1.backgroundColor = RGB(38, 154, 255);
    //    [butt2 layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:5];
    //    [self.lowerPartView addSubview:butt2];
    
    
}





#pragma mark ------- 底部uiview 的操作

- (void)duihuanTap {
    
    DLog(@"兑换 ");
    
    if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
        HWLoginController  *login = [[HWLoginController alloc]init];
        [self.navigationController pushViewController:login animated:YES];
        return;
        
    }
    
    
    
    
    HWxiaohaojifenView *xiaohaoview = [[HWxiaohaojifenView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
    
    xiaohaoview.dataDic = self.dataDic;
    
    [kKeyWindow addSubview:xiaohaoview];
    
    
    //    HWExchangeViewController  *exchange = [[HWExchangeViewController alloc]init];
    //    exchange.dataDic = self.dataDic;
    //    [self.navigationController pushViewController:exchange animated:YES];
    //
    //
    
}

- (void)shoucangTap {
    
    DLog(@"收藏");
    
    if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
        HWLoginController  *login = [[HWLoginController alloc]init];
        [self.navigationController pushViewController:login animated:YES];
        return;
        
    }
    
    
    
    if ([self.shancangStr intValue] == 1) {
        
        
        //  [self.pinglunButon setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        //     [self.pinglunButon setImage:[UIImage imageNamed:@"weishoucang_wu"] forState:UIControlStateNormal];
        
        [self quxiaoshoucang];
        return;
        
    } else {
        
        //    [self.pinglunButon setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        
        
    }
    
    
    
    
    
    NSString *uidStr = [NSString stringWithFormat:@"%@",[HWLocallyStoredData getLoginUserID]];
    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
    
    NSString *typeStr =  [NSString stringWithFormat:@"%@",@"1"];
    
    NSString *singStr = [NSString stringWithFormat:@"%@%@%@",uidStr,tStr,@"fsd213ewdsadqwe2121213edsad"];
    
    NSString *singMD5 = [WMUtil md5HexDigest:singStr];
    
    
    NSDictionary *parametes = @{
        
        @"ios" : @"1",
        @"ct" :  @"app",
        @"ac" : @"shoucang_add",
        @"uid" :uidStr,
        @"t" : tStr,
        @"type" :typeStr,
        @"sign" : singMD5,
        @"id"  : self.goodsID
    };
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        // 取消收藏
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        
        if ([codeStr intValue] == 1) {
            
            [self sendTheRequest];
            
            
            [MBProgressHUD showError:response[@"message"]];
            
            
        } else  {
            
            [MBProgressHUD showError:response[@"message"]];
            
        }
        
        
        
    } failure:^(NSString *error) {
        
        [MBProgressHUD showError:@""];
        
        
    }];
    
    
    
    
    
    
}




- (void)quxiaoshoucang {
    
    //    self.shancangStr = is_shoucang;
    //
    //          if ([is_shoucang intValue] == 0) {
    //
    //              [self.pinglunButon setImage:[UIImage imageNamed:@"weishoucang_wu"] forState:UIControlStateNormal];
    //
    //
    //
    //
    //          } else {
    //
    //               [self.pinglunButon setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    //
    //
    //          }
    //
    
    
    
    NSString *uidStr = [NSString stringWithFormat:@"%@",[HWLocallyStoredData getLoginUserID]];
    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
    
    NSString *typeStr =  [NSString stringWithFormat:@"%@",@"1"];
    
    NSString *singStr = [NSString stringWithFormat:@"%@%@%@",uidStr,tStr,@"fsd213ewdsadqwe2121213edsad"];
    
    NSString *singMD5 = [WMUtil md5HexDigest:singStr];
    
    
    NSDictionary *parametes = @{
        
        @"ios" : @"1",
        @"ct" :  @"app",
        @"ac" : @"shoucang_del",
        @"uid" :uidStr,
        @"t" : tStr,
        @"type" :typeStr,
        @"sign" : singMD5,
        @"member_id":[HWLocallyStoredData getCode],
        @"id"  : self.goodsID
    };
    
    [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
        
        
        // 取消收藏
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        
        if ([codeStr intValue] == 1) {
            
            [self sendTheRequest];
            
            //  [self.pinglunButon setImage:[UIImage imageNamed:@"weishoucang_wu"] forState:UIControlStateNormal];
            [MBProgressHUD showError:response[@"message"]];
            
            
        } else  {
            
            [MBProgressHUD showError:response[@"message"]];
            
        }
        
        
        
    } failure:^(NSString *error) {
        
        [MBProgressHUD showError:@""];
        
        
    }];
}














- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return  0;
    
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellID = @"cellID";
    
    HWFuLishangpingxiangqingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[HWFuLishangpingxiangqingTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        
    }
    
    cell.selectionStyle  = UITableViewCellSelectionStyleNone;
    
    cell.backgroundColor = [UIColor whiteColor];
    
    if (indexPath.row == 9) {
        cell.xiamianFenGexianView.hidden = NO;
        
    } else {
        
        cell.xiamianFenGexianView.hidden = YES;
        
    }
    //
    //    cell.textLabel.text = @"123";
    //    cell.textLabel.textColor = RGB(51, 51, 51);
    return  cell;
    
}



- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 39)];
    view.backgroundColor = [UIColor whiteColor];
    
    
    UILabel    *miashuLabel  =  [[UILabel alloc]initWithFrame:CGRectMake(12, 2, kScreenW, 37)];
    // miashuLabel.text = @"商品详情";
    miashuLabel.textColor = RGB(51, 51, 51);
    miashuLabel.font = [UIFont systemFontOfSize:14];
    //miashuLabel.textAlignment = NSTextAlignmentCenter;
    [view addSubview:miashuLabel];
    
    
    return  view;
    
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return  5;
    // return  35;
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    
    return  39;
}





#pragma mark --------- UICollectionViewDelegate


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    //  5
    return self.dataMuArr.count;
}







- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    UICollectionViewCell *cell =  [collectionView dequeueReusableCellWithReuseIdentifier:@"cellID" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    
    UIImageView *iamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 25, kScreenW, 148)];
    // iamgeView.image = [UIImage imageNamed:@"goods1"];
    iamgeView.contentMode =UIViewContentModeScaleAspectFit;
    iamgeView.backgroundColor = [UIColor whiteColor];
    //  self.icoimageView.image = [UIImage imageNamed:@"goods1"];
    //  iamgeView.backgroundColor = [UIColor yellowColor];
    NSURL *url  = [NSURL URLWithString:self.dataMuArr[indexPath.row]];
    [iamgeView sd_setImageWithURL:url placeholderImage:nil];
    [cell addSubview:iamgeView];
    
    cell.backgroundColor = [UIColor whiteColor];
    
    //    if (indexPath.row%2 == 0)  {
    //         cell.backgroundColor = [UIColor yellowColor];
    //    } else {
    //
    //         cell.backgroundColor = [UIColor redColor];
    //    }
    
    return cell;
    
    
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    return CGSizeMake(SCREEN_WIDTH,200);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    DLog(@"12334");
    
}













@end
